5. custom tile Source
1. Use locationrecttilesource to customize the BIND source with quadkey
Take the Bing online map as an example. Load the Bing map (Simplified Chinese) near Hainan in the control ).
First, analyze the URI of the tile System of Bing map. Here we will use the developer tool provided by Internet Explorer as an example:
Through analysis (how to analyze ......) We can see that the format of the tile system URI of Bing map (Simplified
Coordinate System and map image encoding]
To optimize the map system performance and increase the speed of map download and display, all maps are divided into small square blocks of 256x256 pixels. Because the number of pixels varies at each zoom level, the number of Map Images (tile) is also different:
map width = map height = 2^Leveltiles
Each tile has an XY coordinate value from (0, 0) in the upper left corner to (2 ^ level-1, 2 ^ level-1) in the lower right corner ). For example, at the thr
determine the tile XY coordinates of the tile containing that pixel:
tileX = floor(pixelX / 256)
tileY = floor(pixelY / 256)
To optimize the indexing and storage of tiles, the two-dimenstmtile XY coordinates are combined into one-dimenstmstrings called quadtree keys, or "quadkeys" for short. each quadkey uniquely identifies a single tile at a particle level of detail, and it can be used as an key in Common Database B-tree indexes. to convert tile c
ChinaLayer and GetTile. ashx are selected in blue.
2. GetTile. ashx
1) define the Request Path format:
///
The request Tile is determined by passing three parameters to GetTile. ashx.
2) process parameters in ProcessRequest and return results:
Public void ProcessRequest (HttpContext context) {// obtain the request parameter string type = context. request ["type"]; string format = context. request ["format"]; // check the map type switch (type) {case "china": {// check the map format if (format
key, or "quadkeys" for short ". Each quadkey uniquely identifies a tile at each scaling level. Given a tilexy coordinate system (3, 5) with a zoom level of 3, The quadkey is determined as follows:
Tilex = 3 = 011 2
Tiley = 5 = 101 2
Quadkey = 100111 2 = 213 4 = "213"
3. Download map data
Test data can be downloaded from Google Maps.
4. The result is as follows
) { } }
Through the code block above the Tilesource programming template can be seen, Bingmapstilesource inheritance and Deepzoom core class Multiscaletilesource, its loading picture The algorithm of the data is completed by the Multiscaletilesource instance method Gettilelayers (). So if you want to achieve the tiles path of the Bing maps that you obtained in front of you to get the map data for Bing Maps, you should rewrite the method's implementation to change the way it loads the data.
When writing xml configuration today, one of the strings contains characters and the result is incorrect:
The reason is that XML and HTML are the same. This type of special symbols must be used with escape characters...
The final solution is like this:
Add Key = " Format " Value = " Http: // {0}/gettile. ashx? Type = China Amp; Format = PNG Amp; Quadkey = {quadkey} " />
For oth
*2 level/DPI to get the corresponding inch, and then divide the inch by 0.0254 to the meter. The field distance is still cos (latitude * PI/180) * 2 * pI * 6378137 meters. Therefore, the scale formula is generally set to 1: XXX, with no unit:
Map scale = 1: ground resolution * screen DPI/0.0254 meters/inch
= 256*2 level/screen DPI/0.0254/(COS (latitude * PI/180) * 2 * pI * 6378137)
= 1: (COS (latitude * PI/180) * 2 * pI * 6378137 * screen DPI)/(256*2 level * 0.0254) Quadkeys computing
For
Bingmap for WPF control does not directly provide a map of China, but it is known through Bing map (China) that there is a map of Bing China. After some Baidu, find a solution. Add a new map layer to solve the problem. Use a new layer to overwrite the original map. The new layer displays the China map. The code solves most of the problems (the Code is as follows ):
// Map is the Bing map for WPF control.
Maptilelayer tilelayer;
Private void addtileoverlay ()
{
// Create a new map layer to add th
I believe many people have used the BM Control During WP7 development.
But as a Chinese, looking at the map in English only, I still feel awkward.
So I searched the method on the Internet and implemented it myself. Now I will share it with you!
First, add the following code in the XAML code:
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
Add the following code to the xaml. cs file:
void MainPage_Loaded(object sender, RoutedEventArgs e) {
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.